﻿ 
using SHKF.B2C.Model.Entity.WorkingCenter;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace SHKF.B2C.BLL.WorkingCenter
{
    /// <summary>
    /// ERP商品映射
    /// </summary>
    public class ProductInfoRelatedBLL : WorkingCenterBLL
    {
        public ProductInfoRelatedBLL(SqlSugarClient db) : base(db)
        {

        }

        public List<ProductInfoRelatedEntity> QueryList(long productVSN)
        {
            List<ProductInfoRelatedEntity> list = this.db
                .Queryable<ProductInfoRelatedEntity>()
                .Where(ww => ww.ProductVSN == productVSN)
                .ToList();

            return list;
        }

        public ProductInfoRelatedEntity Save(ProductInfoRelatedEntity info)
        {
            if (info.SN == 0)
            {
                info.SN = this.db.Insertable<ProductInfoRelatedEntity>(info)
                    .ExecuteReturnBigIdentity();
            }
            else
            {
                this.db
                    .Updateable<ProductInfoRelatedEntity>(info)
                    .ExecuteCommand();
            }
            return info;
        }

        public int Delete(long SN)
        {
            int result = this.db.Deleteable<ProductInfoRelatedEntity>().In(SN)
                 .ExecuteCommand();

            return result;
        }

    }
}
